#define BOOST_TEST_MODULE testElementProject

#include <boost/test/unit_test.hpp>

#include "common/elements/element_maker.h"
#include "common/elements/project.h"

BOOST_AUTO_TEST_CASE(testProjectJson)
{
    Elements::ProjectPtr first = std::make_shared<Elements::Project>();
    first->setId(1);
    first->setParentId(3);
    first->setCaption("a");
    first->setDescription("B");

    const auto json = first->toJsonString();
    const Elements::ElementPtr second(Elements::fromJsonString(json));
    BOOST_CHECK(first->isSame(second.get()));

    const auto third = std::static_pointer_cast<Elements::Project>(second);
    BOOST_CHECK(1 == third->id());
    BOOST_CHECK(3 == third->parentId());
    BOOST_CHECK("a" == third->caption());
    BOOST_CHECK("B" == third->description());
    BOOST_CHECK("a" == third->searchCaption());
    BOOST_CHECK("b" == third->searchDescription());
}
